if exists (select 1
            from  sysobjects
           where  id = object_id('bd_kq_approve')
            and   type = 'U')
   drop table bd_kq_approve
go

/*==============================================================*/
/* Table: bd_kq_approve                                         */
/*==============================================================*/
create table bd_kq_approve (
   approve_id           varchar(64)          not null,
   approve_key          varchar(64)          not null,
   approve_name         varchar(200)         not null,
   deployment_id        varchar(64)          not null,
   create_by            int                  not null default 0,
   create_time          datetime             not null default getdate(),
   update_by            int                  not null default 0,
   update_time          datetime             null,
   constraint PK_BD_KQ_APPROVE primary key (approve_id)
)
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'approve_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'approve_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '主键ID',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'approve_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'approve_key')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'approve_key'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '流程的KEY',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'approve_key'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'approve_name')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'approve_name'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '流程名称',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'approve_name'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'deployment_id')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'deployment_id'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '部署的ID',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'deployment_id'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_by')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'create_by'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '创建人',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'create_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'create_time')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'create_time'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '创建时间',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'create_time'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_by')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'update_by'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '修改人',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'update_by'
go

if exists(select 1 from sys.extended_properties p where
      p.major_id = object_id('bd_kq_approve')
  and p.minor_id = (select c.column_id from sys.columns c where c.object_id = p.major_id and c.name = 'update_time')
)
begin
   declare @CurrentUser sysname
select @CurrentUser = user_name()
execute sp_dropextendedproperty 'MS_Description',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'update_time'

end


select @CurrentUser = user_name()
execute sp_addextendedproperty 'MS_Description',
   '最后修改时间',
   'user', @CurrentUser, 'table', 'bd_kq_approve', 'column', 'update_time'
go
